<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>天下行租车</title>
    <script src="https://unpkg.com/vue@2.7.14/dist/vue.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <script src="js.txx.js"></script>
</head>
<body>
<div id="app">
    <myheader></myheader>
    <main class="c900 el-card" style="align-items: stretch; width: 300px">
        <h2>用户登录</h2>
        <el-form label-width="50px" label-position="left">
            <el-form-item label="账号: ">
                <el-input v-model="parm.name" placeholder="账号"></el-input>
            </el-form-item>
            <el-form-item label="密码: ">
                <el-input v-model="parm.pwd" type="password" placeholder="密码"></el-input>
            </el-form-item>
            <el-form-item style="text-align: right">
                <el-link :underline="false" @click="alert('有缘人, 这个功能交给实现你了!')">忘记密码</el-link>
                <el-button @click="login" type="primary">登录</el-button>
            </el-form-item>
        </el-form> 
    </main>
</div>
<script>
    var v = new Vue({
        el : "#app",
        data:{
            parm:{
                name:"",
                pwd:"",
            }
        },
        methods:{
            login(){
                let p = new URLSearchParams();
                for(let name in this.parm){
                    p.append(name,this.parm[name])
                }
                axios.post("LoginServlet.s",p).then(res=>{
                    if (res.data.code){
                        //返回上一个页面
                        //history.back()
                        location.href = "index.html?" + new Date().getTime();
                    }else {
                        this.$alert(res.data.msg);
                    }
                })
            }
        }
    })
</script>
</body>
</html>
